Help:HTML in wikitext
The MediaWiki software allows use of a subset of HTML5 markup elements or tags and their attributes for presentation formatting. Many HTML tags may also be included by equivalent or which are simpler for most editors and less intrusive in the editing window. In normal practice, wiki markup or templates are preferred within articles, but HTML is quite useful for formatting within templates. Tutorials This help page gives only an overview of allowed markup. For further assistance and detailed specifications: * HTML5 Introduction at w3schools.com Attributes HTML attributes provide additional information about an element and are always specified in the start tag. They are formatted as a name/value pair like name="value". Global attributes apply to all tags. Attributes not listed here are not allowed by MediaWiki : * class: one or more classifications to which the element belongs. See Wikipedia:Catalogue of CSS classes. * dir: text direction— "ltr" (left-to-right), "rtl" (right-to-left) or "auto". * id: unique identifier for the element. * lang: primary language for the contents of the element per BCP 47. The MediaWiki software automatically adds the xml:lang attribute whenever lang is defined, but xml:lang will no longer be passed when included as a separate attribute. * style: applies CSS styling to the contents of the element. * title: advisory information associated with the element. HTML5 microdata attributes apply to all tags: * Any attribute beginning with data- * itemid * itemprop * itemref * itemscope * itemtype Other tags such as support specific attributes— these are listed in the appropriate section. The MediaWiki does some cleanup on attributes. A best practice is to use the proper syntax. * Discards attributes not on a whitelist for the given element. * Turns broken or invalid entities into plaintext. * Double-quotes all attribute values. * Attributes without values are given the name as value. * Double attributes are discarded. * Unsafe style attributes are discarded. * Prepends space if there are attributes. Elements These HTML elements are supported by the MediaWiki software. This section gives a brief overview of the HTML element, an example, relevant wikimarkup and templates. Basic h1, h2, h3, h4, h5, h6 The through tags are headings for the sections with which they are associated. is used for the article title. Headings are styled through CSS and added to the page's . }} Wikimarkup: surround the text with the appropriate number of equal signs. Headers formatted with wikimarkup add an edit link. }} Wiki headers use the following default CSS: Templates: for use in documentation p tag places content into a separate paragraph. Wikimarkup: Separate paragraphs by a single blank line. br or inserts a line break. Both versions of the break are supported by HTML5. Templates: * adds multiple line breaks. * adds adds a true carriage return and line feed. * adds a break with styling to clear floating elements. * creates an unbulleted list. hr represents a paragraph-level thematic break and presents as a horizontal rule. Wikimarkup: use ---- ---- }} comment formats the enclosed text as a hidden comment. Formatting abbr creates a tooltip to define an abbreviation or acronym that is displayed on mouse-over. Support: not supported by IE6 or IE7. Templates: ; supports Unicode display b formats text stylistically offset from other text (bold) without conveying extra importance. Wikimarkup: Use ' to open and close bold text. bdi isolates the content from the surrounding text-direction settings. Support: Firefox, Chrome blockquote presents text in an offset block. Templates: ; supports pre-formatted attribution and source parameters. For other specialized quotation templates, see Category:Quotation templates. cite contains the title of a work and by default is formatted in italics. This is a new definition in HTML5— in the previous XML implementation was used to contain a citation or a reference to other sources. code formats a section of computer code. MediaWiki applies CSS styling to display in a monospace font. Templates: uses . data formats a machine-readable version of contents. Attributes: value del formats deleted text. dfn is used for indicating a definition. Templates: em represents a span of text with emphatic stress. Templates: i represents a span of text offset from its surrounding content without conveying any extra emphasis or importance, and for which the conventional typographic presentation is italic text. Wikimarkup: Use '' to open and close italic text. ins indicates a range of text that has been added. Styled as underlined text. Used on talk pages to indicate refactored text; see WP:REDACT. kbd indicates user input such as keyboard input or voice commands. Templates: * applies gray styling * renders illustrated keys and keystrokes. mark represents a run of text in one document marked or highlighted for reference purposes, due to its relevance in another context. Marked text is formatted with a yellow background by default. Support: Not supported by Internet Explorer 8 and below. pre element represents a block of preformatted text. In MediaWiki, is actually a parser tag and not HTML, but the function is the same. HTML entities parses HTML entities. If you want to escape this, replace & with &. Templates: * wraps text that overflows the page. * wraps or uses scrollbox. rp, rt, ruby marks spans of phrasing content with ruby annotations. marks the ruby text component of a ruby annotation. is used to provide parentheses around a ruby text component of a ruby annotation, to be shown by user agents that don’t support ruby annotations. s is used to indicate content that is no longer accurate or relevant and that has been struck from the page. It is not appropriate when indicating document edits; to mark a span of text as having been removed from a document, use . Templates: samp indicates output from a program or computing system. Templates: applies gray styling small format small text. strong formats a span of text with strong importance. Templates: sub formats a span of text as a subscript. Templates: * ( text) * ( text) * ( text) * ( text) * ( text) * (text ) * (1.23 ) sup formats a span of text as a superscript. Templates: * ( text) * ( text) * ( text) * ( text) * ( text) * (text ) * (1.23 ) time defines either a time (24 hour clock), or a date in the Gregorian calendar, optionally with a time and a time-zone offset. Attributes: datetime Support: Not supported by Internet Explorer 8 and below. u represents a span of text offset from its surrounding content without conveying any extra emphasis or importance, and for which the conventional typographic presentation is underlining; for example, a span of text in Chinese that is a proper name (a Chinese proper name mark), or span of text that is known to be misspelled. Templates: var formats text in italics to indicate a variable in a mathematical expression or programming context, or placeholder text that the reader is meant to mentally replace with some other literal value. Templates: * * formatted in italic serif to differentiate characters Lists Do not leave blank lines between items in a list unless there is a reason to do so, since this causes the MediaWiki software to interpret each item as beginning a new list. dl, dt, dd , and are used to create a definition list of group names corresponding to values. Group names are in bold and values are indented. Each group must include one or more definitions. Wikimarkup: is created using ; while automatically enclosed in . is created using : for each value. For a single or first value the : can be placed on the same line after ; where subsequent values must be placed on separate lines. Templates: ol, ul, li represents an ordered list; represents an unordered list; represents a list item within either type of list. Wikimarkup: use * for items in an unordered list and # for ordered lists. # Item1 # Item2 # Item3 # Item4 |3=* Item1 * Item2 * Item3 * Item4 |4= * Item1 * Item2 * Item3 * Item4 }} Templates: for a variety of specialized uses, see Category:Wikipedia list formatting templates. Containers div is a generic container for flow content that displays as a block element. span is a container for flow content that displays as an inline element. Tables table, td, tr defines a table. defines a table row. defines a data cell with contents that may include text, links, images, lists, forms, other tables, etc. Attributes: * : border * : headers, rowspan, colspan * The scope attribute is allowed only when using the table header wikimarkup (!). * Allowed but obsolete or unsupported: abbr, axis, align, charoff, char, valign th defines a table header; styled as centered and bold. caption adds a caption to a table. thead, tfoot, tbody , and are not supported, but are automatically generated when the page is rendered. Obsolete elements These elements are now obsolete in HTML5, but still supported by browsers. These tags either have an alternate tag or a template that replaces their function with CSS. big (obsolete)}} formats text in a larger font size. Templates: uses CSS. center (obsolete)}} is used to center text elements. Templates: uses CSS. font (obsolete)}} is used to set the font size, font face and color of text. Templates: uses CSS. rb (obsolete)}} Formerly used to mark base text in a ruby annotation; use . strike }} (obsolete) formats strike-through characters; use instead. tt (obsolete)}} formats text in a fixed-width font. Use , , or instead. Unsupported elements These elements are not supported, but have equivalent wiki markup. Attempting to use any element not whitelisted by will result in the markup showing as plain text. a is used to create links. Use the wikimarkup for internal links and [ ] for external links. input is used to create forms. The extension tag is used to create a text box with a button. HTML Tidy HTML Tidy is enabled for the English Wikipedia. Tidy parses the MediaWiki output and cleans it up to ensure that valid HTML is rendered. For example, , , , will all render as . Tidy is not enabled for . Tidy is not perfect, and has been known to introduce errors. Exceptions In some pages in the MediaWiki namespace (typically the short messages like button labels) HTML is not parsed and tags will be exposed. User and sitewide CSS and JS pages (see ) are interpreted as if inside a block. Validation The MediaWiki software attempts to fix HTML errors, but it does not catch all of them. Where HTML is used, it is helpful to verify it with the W3C Markup Validation Service. Parser and extension tags The MediaWiki software adds elements that look and act like HTML tags. Parser tags are included in MediaWiki whereas extension tags are added by optional software extensions. Installed tags are listed at . ;Parser tags : , , ;Extension tags : , , , , , , , , , , (alias ), module. }} External links * HTML 4.01 specification: elements | attributes Category:Wikipedia editor handbook Category:Wikipedia editor help